package com.ningxun.pagentcrawler.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;

import java.time.LocalDateTime;

/**
 * 爬虫任务实体类
 * 用于记录爬虫执行历史
 */
public class CrawlerTask {
    
    private String id;
    
    /**
     * 任务名称
     */
    private String taskName;
    
    /**
     * 配置ID
     */
    private String configId;
    
    /**
     * 配置名称
     */
    private String configName;
    
    /**
     * 任务状态：RUNNING, SUCCESS, FAILED, CANCELLED
     */
    private String status;
    
    /**
     * 开始时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime startTime;
    
    /**
     * 结束时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime endTime;
    
    /**
     * 爬取数量
     */
    private Integer crawledCount;
    
    /**
     * 保存数量
     */
    private Integer savedCount;
    
    /**
     * 失败数量
     */
    private Integer failedCount;
    
    /**
     * 错误信息
     */
    private String errorMessage;
    
    /**
     * 执行时长(毫秒)
     */
    private Long duration;
    
    /**
     * 创建者
     */
    private String createBy;
    
    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;
    
    // 默认构造函数
    public CrawlerTask() {}
    
    // Getter和Setter方法
    public String getId() {
        return id;
    }
    
    public void setId(String id) {
        this.id = id;
    }
    
    public String getTaskName() {
        return taskName;
    }
    
    public void setTaskName(String taskName) {
        this.taskName = taskName;
    }
    
    public String getConfigId() {
        return configId;
    }
    
    public void setConfigId(String configId) {
        this.configId = configId;
    }
    
    public String getConfigName() {
        return configName;
    }
    
    public void setConfigName(String configName) {
        this.configName = configName;
    }
    
    public String getStatus() {
        return status;
    }
    
    public void setStatus(String status) {
        this.status = status;
    }
    
    public LocalDateTime getStartTime() {
        return startTime;
    }
    
    public void setStartTime(LocalDateTime startTime) {
        this.startTime = startTime;
    }
    
    public LocalDateTime getEndTime() {
        return endTime;
    }
    
    public void setEndTime(LocalDateTime endTime) {
        this.endTime = endTime;
    }
    
    public Integer getCrawledCount() {
        return crawledCount;
    }
    
    public void setCrawledCount(Integer crawledCount) {
        this.crawledCount = crawledCount;
    }
    
    public Integer getSavedCount() {
        return savedCount;
    }
    
    public void setSavedCount(Integer savedCount) {
        this.savedCount = savedCount;
    }
    
    public Integer getFailedCount() {
        return failedCount;
    }
    
    public void setFailedCount(Integer failedCount) {
        this.failedCount = failedCount;
    }
    
    public String getErrorMessage() {
        return errorMessage;
    }
    
    public void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
    }
    
    public Long getDuration() {
        return duration;
    }
    
    public void setDuration(Long duration) {
        this.duration = duration;
    }
    
    public String getCreateBy() {
        return createBy;
    }
    
    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }
    
    public LocalDateTime getCreateTime() {
        return createTime;
    }
    
    public void setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
    }
    
    @Override
    public String toString() {
        return "CrawlerTask{" +
                "id='" + id + '\'' +
                ", taskName='" + taskName + '\'' +
                ", configName='" + configName + '\'' +
                ", status='" + status + '\'' +
                ", crawledCount=" + crawledCount +
                ", savedCount=" + savedCount +
                ", failedCount=" + failedCount +
                ", duration=" + duration +
                '}';
    }
} 